package com.qingcheng.controller;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author: LDeng
 * @Date: 2020-07-16 10:07
 */

@Controller // Controller 可以跳转地址 ， RestController 响应JSON 字符串
@RequestMapping(value="/redirect")
public class RedirectController {

    //跳转方法
    //url :/redirect/back
    //referer:用户访问该方法的来源页面地址
    @RequestMapping(value="/back")
    public String back(@RequestHeader(value="referer",required=false)String referer){
        if(!StringUtils.isEmpty(referer)){//不为空跳回原来页面
            return "redirect:"+referer;
        }
        return "/seckill-index.html";//为空跳回首页
    }

}
